import * as Cesium from "cesium/Cesium";
export default class Util_Cesium{
    constructor(){

    }
    static update3dtilesByMaxtrix(params,matrix) {
        //旋转
        //平移
        let position = Cesium.Cartesian3.fromDegrees(params.px, params.py, params.pz);
        let m = Cesium.Transforms.eastNorthUpToFixedFrame(position);



        // //缩放


        let mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(params.rx));
        let my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(params.ry));
        let mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(params.rz));
        let rotationX = Cesium.Matrix4.fromRotationTranslation(mx);
        let rotationY = Cesium.Matrix4.fromRotationTranslation(my);
        let rotationZ = Cesium.Matrix4.fromRotationTranslation(mz);
        //旋转、平移矩阵相乘
        Cesium.Matrix4.multiply(m, rotationX, m);
        Cesium.Matrix4.multiply(m, rotationY, m);
        Cesium.Matrix4.multiply(m, rotationZ, m);

        let scale=null;
        if (params.scale){
            scale= Cesium.Matrix4.fromUniformScale(params.scale);
        }else{
            scale = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(params.sx,params.sy,params.sz));
        }
        Cesium.Matrix4.multiply(m, scale, m);
        //赋值给tileset
        return m;
    }
    static update3dtilesMaxtrix(params) {
        //旋转
        //平移
        let position = Cesium.Cartesian3.fromDegrees(params.px, params.py, params.pz);
        let m = Cesium.Transforms.eastNorthUpToFixedFrame(position);



        // //缩放


        let mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(params.rx));
        let my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(params.ry));
        let mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(params.rz));
        let rotationX = Cesium.Matrix4.fromRotationTranslation(mx);
        let rotationY = Cesium.Matrix4.fromRotationTranslation(my);
        let rotationZ = Cesium.Matrix4.fromRotationTranslation(mz);
        //旋转、平移矩阵相乘
        Cesium.Matrix4.multiply(m, rotationX, m);
        Cesium.Matrix4.multiply(m, rotationY, m);
        Cesium.Matrix4.multiply(m, rotationZ, m);

        let scale=null;
        if (params.scale){
            scale= Cesium.Matrix4.fromUniformScale(params.scale);
        }else{
            scale = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(params.sx,params.sy,params.sz));
        }
        Cesium.Matrix4.multiply(m, scale, m);
        //赋值给tileset
        return m;
    }
}
